---
root: "/v5.1"
layout: "default"
title: "precondition"
keywords: ""
description: "Swift documentation for 'precondition'"
---

<div class="intro-declaration"><code class="language-swift">func precondition(_:_:file:line:)(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)</code></div><div class="discussion comment"><p>Checks a necessary condition for making forward progress.
</p>
<p>Use this function to detect conditions that must prevent the program from
proceeding, even in shipping code.</p>
</div>